local lockDistance = 20.0
vehicle = nil
function getVehicle()
local player = PlayerPedId()
local coords = GetEntityCoords(player)
local entityWorld = GetOffsetFromEntityInWorldCoords(GetPlayerPed(-1), 0.0, lockDistance, 0.0)
local rayHandle = CastRayPointToPoint(coords.x, coords.y, coords.z, entityWorld.x, entityWorld.y, entityWorld.z, 10, GetPlayerPed(-1), 0)
local a, b, c, d, targetVehicle = GetRaycastResult(rayHandle)
    if (targetVehicle ~= nil and targetVehicle ~= 0) then
        vehicle = targetVehicle
    else
        ShowNotification("车辆 ~r~未找到")
    end
end
RegisterCommand("hijack", function()
            getVehicle()
    local vehcoords = GetEntityCoords(vehicle)
	local coords = GetEntityCoords(PlayerPedId())
	local isLocked = GetVehicleDoorLockStatus(vehicle)
num = math.random(0,100)
        to = num % 2
        if to == 0 or isLocked==1 then
            ShowNotification("车辆 ~r~解锁失败，或许它是开着的？")
        else
    if DoesEntityExist(vehicle) then
        if #(vehcoords - coords) < lockDistance then
            TaskStartScenarioInPlace(GetPlayerPed(-1), "WORLD_HUMAN_WELDING", 0, true)
            Wait(15000)
            ClearPedTasksImmediately(GetPlayerPed(-1))
            SetVehicleDoorsLocked(vehicle,1)
            ShowNotification("车辆 ~g~解锁")
        end
    end
        end
end)
function ShowNotification(text)
    SetNotificationTextEntry("STRING")
    AddTextComponentString(text)
    DrawNotification(false, false)
end